<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>个人信息页</title>
    <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/index.css" rel="stylesheet">
    <script src="/jquery/jquery2.1.4.js"></script>
    <script src="/layer/layer.js"></script>
    <script src="/bootstrap/js/bootstrap.min.js"></script>
</head>

<body>
<div class="dingbu">
    <div class="denglu-font top">
        <!--         <a href="/" id="dingbuhome"><img src="/images/logo.jpg"></a>-->

        <!--        <div id="so" style="position: relative; left: 350px;top:8px;width: 100px; float: left;" class="top">-->
        <!--            <div class="input-group">-->
        <!--                <input type="text" class="form-control" id="searchText" style="width: 380px;">-->
        <!--                <span class="input-group-addon" id="search" onclick="search()"><i class="glyphicon glyphicon-search"-->
        <!--                                                                                  style="color: #0055aa;"> <span>搜索-->
        <!--                                </span></i></span>-->
        <!--            </div>-->
        <!--        </div>-->
        <div class="denglu-font2 top">
            <a href="/" id="dingbuhome">返回首页</a>
            <a href="/" id="want">发布求购</a>
            <a href="/" id="cart">我的购物车</a>
            <a href="#" id="release1">发布商品</a>
            <!--            <a href="#" id="uname">zyl</a>-->
            <a href="login" id="login_logout">登录</a>
        </div>
        <div style="clear:both"></div>
    </div>
</div>

<div class="row" id="myHome_top">
    <div class="col-md-10 col-md-offset-1" style="background-color: #ffffff; border-radius: 2px;">
        <div class="row">
            <div class="img-and-button">
                <div class="col-md-2">
                    <!-- 用户头像 -->
                    <img src="/images/logo4.png">
                </div>
                <div class="col-md-3 col-xs-7">
                    <button type="button" class="btn btn-info" style="margin: 15px 36px" data-toggle="modal"
                            data-target="#edit"
                            id="edituser">
                        <span class="glyphicon glyphicon-pencil"></span> 编辑资料
                    </button>
                </div>
            </div>
            <div class="col-md-10 col-xs-12" style="float: left;width: 300px;height: 300px;margin: -10px 0 5px 90px">
                <br><br><br>
                <div class="row">
                    <div class="col-md-10">
                        <!-- 用户名 -->
                        <b id="myself_name" style="font-size: 22px;" th:text="${user.username}">zyl</b>
                        &nbsp;&nbsp;&nbsp;
                    </div>
                </div>
                <br>
                <div class="stu-info">
                    <div class="stu-info-part">
                        <div class="row">
                            <div class="col-md-12">
                                <!-- realName -->
                                <b>姓名</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span id="myself_family"
                                                                                     th:text="${user.realName}">张一隆</span>
                            </div>
                        </div>
                        <br>
                        <div class="row">

                            <div class="col-md-12">
                                <!-- gender -->
                                <b>性别</b> &nbsp;&nbsp;&nbsp; <span id="myself_sex"
                                                                   th:text="${user.gender}==0?'男':'女'">男</span>
                            </div>
                        </div>
                        <br>
                        <div class="row">
                            <div class="col-md-12">
                                <!-- academy grade studentNumber -->
                                <b>学号</b> &nbsp;&nbsp;&nbsp; <span id="myself_student2" th:text="${user.studentNumber}">2018303107</span>
                            </div>
                        </div>
                        <br>
                    </div>
                    <div class="stu-info-part">
                        <div class="row">
                            <div class="col-md-12">
                                <!-- phoneNumber -->
                                <b>手机号</b> &nbsp;&nbsp;&nbsp; <span id="myself_intro"
                                                                    th:text="${user.phoneNumber}">15109918030</span>
                            </div>
                        </div>
                        <br>
                        <div class="row">
                            <div class="col-md-12">
                                <!-- email -->
                                <b>邮箱</b> &nbsp;&nbsp;&nbsp; <span id="myself_email"
                                                                   th:text="${user.email}">976235949@qq.com</span>
                            </div>
                        </div>
                        <br>
                        <div class="row">
                            <div class="col-md-12">
                                <!-- academy grade studentNumber -->
                                <b>学院</b> &nbsp;&nbsp;&nbsp; <span id="myself_student1"
                                                                   th:text="${user.academy}">软件学院</span>
                            </div>
                        </div>
                    </div>
                    <div style="clear:both"></div>
                </div>
            </div>
            <div style="clear:both"></div>
        </div>
    </div>
</div>

<!--下半部分 -->
<div class="row" id="myHome_bottom" style="position: relative; top: 10px;">
    <div class="col-md-10 col-md-offset-1" style="background-color: #ffffff; border-radius: 2px;">
        <div>
            <!-- Nav tabs -->
            <ul class="nav nav-tabs" role="tablist">
                <!-- 我的发布 -->
                <li role="presentation" class="active" id="tab_dynamic">
                    <a href="#release" aria-controls="home" role="tab" data-toggle="tab">我的发布 <samp
                            id="my_release"></samp></a>
                </li>
                <!-- 我的订单 -->
                <li role="presentation" id="tab_answer">
                    <a href="#order" aria-controls="profile" role="tab" data-toggle="tab">我的订单 <samp
                            id="my_order"></samp></a>
                </li>
                <!-- 我的求购 -->
                <li role="presentation" id="tab_attention">
                    <a href="#wants" aria-controls="attention" role="tab" data-toggle="tab">我的求购 <samp
                            id="my_wants"></samp></a>
                </li>
                <!-- 我的收藏 -->
                <li role="presentation" id="tab_collect">
                    <a href="#collect" aria-controls="collect" role="tab" data-toggle="tab">我的收藏 <samp
                            id="my_collect"></samp></a>
                </li>
                <!-- 我的地址 -->
                <li role="presentation" id="tab_address">
                    <a href="#address" aria-controls="collect" role="tab" data-toggle="tab">我的地址 <samp
                            id="my_address"></samp></a>
                </li>
            </ul>


            <!-- Tab panes -->
            <div class="tab-content">
                <br>
                <!--################################################### 发布的商品信息 ###################################################-->
                <div role="tabpanel" class="tab-pane active" id="release">

                    <!-- 商品展示-循环 - 模板 -->
                    <div id="myself_release" style="display: block" th:each="item:${user.items}" th:object="${item}">

                        <div class="myself_release_num">
                            <div class="row">
                                <!-- 配图 -->
                                <div class="col-xs-12 col-md-3" id="myself_release_photo"
                                     style="cursor:pointer; width: 250px;">
                                    <!-- 图片 -->
                                    <img th:src="*{image}" alt=""
                                         style="position: relative; height: 150px; border-radius: 3px;">
                                </div>
                                <div class="col-xs-12 col-md-3" id="myself_release_status"
                                     style="width: 200px; position: relative;top: auto;height: auto;">
                                    <h3 th:if="${item.status} eq 0" style="color: #ffc400">审核中</h3>
                                    <h3 th:if="${item.status} eq 1" style="color: #4cae4c">已通过</h3>
                                    <h3 th:if="${item.status} eq -1" style="color: #c12e2a">未通过</h3>
                                </div>
                                <div class="col-xs-12 col-md-7">
                                    <!-- 名称 -->
                                    <div style="overflow: hidden;white-space: nowrap;text-overflow:ellipsis;color: #000000;">
                                        <a th:href="'/api/item/details?itemId=' + *{id} + '&userId=' + ${user.encode()}"
                                           th:text="*{itemName}"
                                           style="cursor:pointer; font-size:18px;">简约时尚水泥花瓶1
                                        </a>
                                    </div>
                                    <!-- 价格 -->
                                    <div style="cursor:pointer;overflow: hidden;text-overflow:ellipsis;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 3;">
											<span th:text="'单价：￥' + *{price}"
                                                  style="word-break: break-word;line-height: 1.6;">单价：￥450</span>
                                    </div>
                                    <!-- 介绍 -->
                                    <div>
                                        <p th:text="*{description}"
                                           style="word-break: break-word;line-height: 1.6;">这是一款很好吃的酸辣粉</p>
                                    </div>
                                </div>

                            </div>
                            <div class="row">
                                <div class="col-xs-7 col-md-10"></div>

                                <!-- 删除 -->
                                <div class="col-xs-2 col-md-1" th:id="*{id}">
                                    <!--                                    <form>-->
                                    <div class="show-btn" style="right: 90px">
                                        <button type="button"
                                                class="btn btn-danger btn-sm itemdel">修改
                                        </button>
                                    </div>
                                    <div class="show-btn" style="right: 1px">
                                        <button type="button" id="myself_release_del"
                                                class="btn btn-danger btn-sm itemdel">删除
                                        </button>
                                    </div>
                                    <!--                                    </form>-->
                                </div>
                            </div>
                            <!-- 商品展示-循环-end -->
                            <hr style="height:1px;border:none;border-top:1px solid #bbbbbb;">
                        </div>
                    </div>
                    <div class="row">
                        <br><br><br><br>
                        <div class="col-xs-12 col-md-4">
                            <h3 style="color: #999999">没有更多发布了</h3>
                        </div>
                        <br><br><br><br>
                    </div>
                </div>
                <!--################################################### 发布商品-end ###################################################-->

                <!--################################################### 我的订单 ###################################################-->
                <div role="tabpanel" class="tab-pane" id="order">

                    <!-- 订单展示-循环 - 模板 -->
                    <div id="myself_order" style="display: block" th:each="order:${orders}" th:object="${order}">
                        <div class="row">
                            <!-- 配图 -->
                            <div class="col-xs-12 col-md-3" style="cursor:pointer;">
                                <!-- 图片 -->
                                <img th:src="*{item.image}" alt=""
                                     style="position: relative; height: 150px; border-radius: 3px;">
                            </div>
                            <div class="col-xs-12 col-md-7">
                                <!-- 名称 -->
                                <div id="1"
                                     style="overflow: hidden;white-space: nowrap;text-overflow:ellipsis;color: #000000;">
                                    <h3 th:text="*{item.itemName}" style="cursor:pointer; font-size:18px;">简约时尚水泥花瓶2
                                    </h3>
                                </div>
                                <!-- 价格 -->
                                <div id="2"
                                     style="cursor:pointer;overflow: hidden;text-overflow:ellipsis;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 3;">
										<span th:text="'单价：￥' + *{item.price}"
                                              style="word-break: break-word;line-height: 1.6;">单价：￥450</span>
                                </div>
                                <!-- 介绍 -->
                                <div id="3"
                                     style="">
										<span th:text="*{item.description}"
                                              style="word-break: break-word;line-height: 1.6;">这是一款很好吃的酸辣粉</span>
                                </div>
                            </div>
                            <div class="col-xs-12 col-md-3">
                                <!-- 购买数量 -->
                                <div id="4"
                                     style="overflow: hidden;white-space: nowrap;text-overflow:ellipsis;color: #000000;">
                                    <br>
                                    <span th:text="'购买数量:'+*{itemCount}" style="cursor:pointer;">购买数量：1
										</span>
                                </div>
                                <!-- 总价格 -->
                                <div id="5"
                                     style="cursor:pointer;overflow: hidden;text-overflow:ellipsis;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 3;">
										<span th:text="'订单金额：￥' + *{totalPrice}"
                                              style="word-break: break-word;line-height: 1.6;">订单金额：￥450</span>
                                </div>
                                <!-- 购买时间 -->
                                <div id="6"
                                     style="overflow: hidden;white-space: nowrap;text-overflow:ellipsis;color: #000000;display: inline;">
										<span th:text="'购买时间：'+*{createTime}"
                                              style="word-break: break-word;line-height: 1.6;">购买时间：2020-1-1</span>
                                </div>
                            </div>
                            <hr style="height:1px;border:none;border-top:1px solid #bbbbbb;">
                        </div>
                        <div class="row">
                            <div class="col-xs-7 col-md-10"></div>

                            <!-- 删除 -->

                            <hr style="height:1px;border:none;border-top:1px solid #bbbbbb;">
                        </div>

                    </div>
                    <div class="row">
                        <br><br><br><br>
                        <div class="col-xs-12 col-md-4">
                            <h3 style="color: #999999">没有更多订单了</h3>
                        </div>
                        <br><br><br><br>
                    </div>
                </div>
                <!--################################################### 我的订单-end ###################################################-->

                <!--################################################### 我的求购 ###################################################-->
                <div role="tabpanel" class="tab-pane" id="wants">

                    <div class="tab-content" th:each="wants:${wants}" th:object="${wants}">
                        <div class="row">
                            <!-- 配图 -->
                            <div class="col-xs-12 col-md-3" style="cursor:pointer;">
                                <!-- 图片 -->
                                <img th:src="*{image}" alt=""
                                     style="position: relative; height: 150px; border-radius: 3px;">
                            </div>
                            <div class="col-xs-12 col-md-7">
                                <!-- 求购标题 -->
                                <div style="overflow: hidden;white-space: nowrap;text-overflow:ellipsis;color: #000000;">
                                    <a th:href="'/api/wants/details?wantsId=' + *{id}" th:text="'求购标题：'+*{title}"
                                       style="cursor:pointer; font-size:18px;">求购标题：花瓶
                                    </a>
                                </div>
                                <!-- 价格 -->
                                <div style="cursor:pointer;overflow: hidden;text-overflow:ellipsis;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 3;">
										<span th:text="'求购时间：' + *{createTime}"
                                              style="word-break: break-word;line-height: 1.6;">求购时间：createTime</span>
                                </div>
                                <!-- 介绍 -->
                                <div>
										<span th:text="'求购描述：' + *{description}"
                                              style="word-break: break-word;line-height: 1.6;">求购描述：这是一款很好吃的酸辣粉</span>
                                </div>
                            </div>

                        </div>
                        <div class="row">
                            <div class="col-xs-7 col-md-10"></div>

                            <!-- 删除 -->
                            <div class="col-xs-2 col-md-1" th:id="*{id}">
                                <form>
                                    <button type="button" id="myself_wants_del"
                                            class="btn btn-danger btn-sm wantsdel">删除
                                    </button>
                                </form>
                            </div>
                        </div>
                        <hr style="height:1px;border:none;border-top:1px solid #bbbbbb;">
                    </div>
                    <div class="row">
                        <br><br><br><br>
                        <div class="col-xs-12 col-md-4">
                            <h3 style="color: #999999">没有更多求购了</h3>
                        </div>
                        <br><br><br><br>
                    </div>
                </div>

                <!--################################################### 我的求购-end ###################################################-->

                <!--################################################### 收藏 ###################################################-->
                <div role="tabpanel" class="tab-pane" id="collect">

                    <div class="tab-content" th:each="collection:${collections}" th:object="${collection}">
                        <div class="row">
                            <!-- 配图 -->
                            <div class="col-xs-12 col-md-3" id="myself_article_photo" style="cursor:pointer;">
                                <!-- 图片 -->
                                <img th:src="*{image}" alt=""
                                     style="position: relative; height: 150px; border-radius: 3px;">
                            </div>
                            <div class="col-xs-12 col-md-7">
                                <!-- 名称 -->
                                <div style="overflow: hidden;white-space: nowrap;text-overflow:ellipsis;color: #000000;">
                                    <a th:href="'/api/item/details?itemId=' + *{id} + '&userId=' + ${user.encode()}"
                                       th:text="*{itemName}"
                                       style="cursor:pointer; font-size:18px;">简约时尚水泥花瓶1
                                    </a>
                                </div>
                                <!-- 价格 -->
                                <div style="cursor:pointer;overflow: hidden;text-overflow:ellipsis;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 3;">
										<span th:text="'单价：￥' + *{price}"
                                              style="word-break: break-word;line-height: 1.6;">单价：￥450</span>
                                </div>
                                <!-- 介绍 -->
                                <div>
										<span th:text="*{description}"
                                              style="word-break: break-word;line-height: 1.6;">这是一款很好吃的酸辣粉</span>
                                </div>
                            </div>

                        </div>
                        <div class="row">
                            <div class="col-xs-7 col-md-10"></div>

                            <!-- 删除 -->
                            <div class="col-xs-2 col-md-1" th:id="*{id}">
                                <form>
                                    <button type="button" id="myself_collection_del"
                                            class="btn btn-danger btn-sm collectdel">删除
                                    </button>
                                </form>
                            </div>
                        </div>
                        <hr style="height:1px;border:none;border-top:1px solid #bbbbbb;">
                    </div>
                    <div class="row">
                        <br><br><br><br>
                        <div class="col-xs-12 col-md-4">
                            <h3 style="color: #999999">没有更多收藏了</h3>
                        </div>
                        <br><br><br><br>
                    </div>
                </div>
                <!--################################################### 收藏-end ###################################################-->

                <!--################################################### 地址 ###################################################-->
                <div role="tabpanel" class="tab-pane" id="address">

                    <div class="row">
                        <div class="col-xs-2 col-md-1">
                            <form class="form_articleUpdate">
                                <button id="form_addressUpdate_button" type="button"
                                        class="btn btn-info btn-sm">新增
                                </button>
                            </form>
                        </div>
                    </div>
                    <!-- 商品展示-循环 - 模板 -->
                    <div id="myself_address" style="display: block" th:each="add:${address}" th:object="${add}">

                        <div class="myself_release_num">
                            <div class="row">

                                <div class="col-xs-12 col-xs-offset-6">
                                    <!-- 名称 -->
                                    <div id=""
                                         style="overflow: hidden;white-space: nowrap;text-overflow:ellipsis;color: #000000;">
                                        <span th:text="*{detail}"
                                              style="cursor:pointer; font-size:18px;">地址详情
                                        </span>
                                    </div>
                                </div>

                            </div>
                            <div class="row">
                                <div class="col-xs-7 col-md-10"></div>
                                <!-- 修改 -->

                                <!-- 删除 -->
                                <div class="col-xs-2 col-md-1">
                                    <form>
                                        <button type="button" id="myself_address_del"
                                                class="btn btn-danger btn-sm"><a
                                                th:href="'/api/user/delAddress?addressId=' + *{id}"
                                                style="color: white;text-decoration: none;">删除</a>
                                        </button>
                                    </form>
                                </div>
                            </div>
                            <!-- 商品展示-循环-end -->
                            <hr style="height:1px;border:none;border-top:1px solid #bbbbbb;">
                        </div>
                    </div>
                    <div class="row">
                        <br><br><br><br>
                        <div class="col-xs-12 col-md-4">
                            <h3 style="color: #999999">没有更多地址了</h3>
                        </div>
                        <br><br><br><br>
                    </div>
                </div>
                <!--################################################### 地址-end ###################################################-->
            </div>
        </div>
    </div>
</div>

<!--###################################################个人信息修改的弹窗-start###############################################-->
<div class="modal fade" id="modifyinfo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">×</span></button>
                <h4 class="modal-title">修改</h4>
            </div>
            <div class="modal-body">

                <div class="form-group">
                    <label for="modifyname">姓名</label>
                    <input type="text" class="form-control" id="modifyname" placeholder="请输入姓名">
                </div>
                <div class="form-group">
                    <label for="modifyphone">手机号</label>
                    <input type="text" name="txt_parentdepartment" class="form-control" id="modifyphone"
                           placeholder="手机号">
                </div>
                <div class="form-group">
                    <label for="modifyemail">邮箱</label>
                    <input type="email" class="form-control" id="modifyemail" placeholder="请输入邮箱">
                </div>
                <div class="form-group">
                    <label for="modifyacademy">学院</label>
                    <input type="email" class="form-control" id="modifyacademy" placeholder="请输入学院">
                </div>
                <div class="form-group">
                    <label for="modifycode">学号</label>
                    <input type="email" class="form-control" id="modifycode" placeholder="请输入学号">
                </div>
                <div class="form-group">
                    性别<br>
                    <input id="male" type="radio" name="sex" value="male" checked>男<br>
                    <input id="female" type="radio" name="sex" value="female">女
                </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><span
                        class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭
                </button>
                <button type="button" id="btn_submit2" class="btn btn-primary" data-dismiss="modal"><span
                        class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存
                </button>
            </div>
        </div>
    </div>
</div>
<!--###################################################个人信息修改的弹窗-start###############################################-->

<!--###################################################地址修改的弹窗-start###############################################-->
<div class="modal fade" id="modifyadd" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="myModalLabel">新增</h4>
            </div>
            <div class="modal-body">

                <div class="form-group">
                    <label for="modifyname">地址</label>
                    <input type="text" class="form-control" id="modifyaddr" placeholder="请输入地址">
                </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><span
                        class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭
                </button>
                <button type="button" id="btn_submit1" class="btn btn-primary" data-dismiss="modal"><span
                        class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存
                </button>
            </div>
        </div>
    </div>
</div>
<!--###################################################地址修改的弹窗-start###############################################-->


</body>
<script>
    function search() {
        console.log($('#searchText').val())
        var data = $('#searchText').val()
        location.assign('/search?keyword=' + data)
    }

    $('#login_logout').click(function () {
        localStorage.clear()
    })
    $(function () {
        load_data()
    })

    //设置顶部栏的登录/退出按钮和用户名显示

    function load_data() {
        var theme = localStorage.getItem('username')
        var userId = localStorage.getItem('userId')

        console.log(localStorage.getItem('username'))
        console.log(localStorage.getItem('userId'))
        if (theme == null || theme == '') {
            $('#login_logout').text('登录')
            $('#uname').text('')
            $('#want').hide()
            $('#release1').hide()
            $('#cart').hide()
        } else {
            $('#login_logout').text('退出')
            $('#login_logout').attr('href', '/logout')
            $('#uname').text(theme)
            $('#want').show()
            $('#want').attr('href', '/api/wants/release?userId=' + userId)
            $('#release1').show()
            $('#release1').attr('href', '/release')
            $('#cart').show()
            $('#cart').attr('href', '/api/cart/all?userId=' + userId)
            $('#uname').attr('href', '/api/user/info?userId=' + userId)
        }
    }

    $('#edituser').on('click', function () {
        console.log('click')
        var name = $('#myself_family').text()
        var phone = $('#myself_intro').text()
        var email = $('#myself_email').text()
        var gender = $('#myself_sex_age').text()
        var address = $('#myself_address').text()
        var academy = $('#myself_student1').text()
        var studentNumber = $('#myself_student2').text()
        console.log(name + phone + email + address)
        $('#modifyname').val(name)
        $('#modifyphone').val(phone)
        $('#modifyemail').val(email)
        $('#modifyacademy').val(academy)
        $('#modifycode').val(studentNumber)

        if (gender == '女') {
            $('#female').prop('checked', 'checked')
        }
        $('#modifyinfo').modal('show')
    })

    $('#form_addressUpdate_button').on('click', function () {
        $('#modifyadd').modal('show')
    })

    function changelabel() {
        var level = $('#modifylevel').val()
        if (level == 10) {
            $('#levellabel').text('全新')
        } else {
            $('#levellabel').text(level + '成新')
        }
    }

    $('#btn_submit1').click(function () {

        var address = $('#modifyaddr').val()

        console.log(address)

        var userId = localStorage.getItem('userId')

        console.log(btoa(userId))
        console.log(atob(btoa(userId)))
        var data = {
            'address': address
        }
        $.ajax({
            url: '/api/user/addAddress?userId=' + userId,
            data: JSON.stringify(data),
            type: 'POST',
            contentType: 'application/json',
            dataType: 'json',
            traditional: true,
            success: function (data) {
                layer.msg(data.msg)
                console.log(data.msg)
                location.reload()
            }
        })
    })

    $('#btn_submit2').click(function () {
        var realName = $('#modifyname').val()
        var phoneNumber = $('#modifyphone').val()
        var email = $('#modifyemail').val()
        var academy = $('#modifyacademy').val()
        var studentNumber = $('#modifycode').val()
        var gender = $('#modifyinfo').find('input[type=\'radio\']:checked').val()
        console.log(gender)
        if (gender == 'female') {
            gender = 1
        } else {
            gender = 0
        }
        console.log(gender)
        userId = localStorage.getItem('userId')
        var data = {
            'realName': realName,
            'phoneNumber': phoneNumber,
            'email': email,
            'academy': academy,
            'studentNumber': studentNumber,
            'gender': gender
        }
        $.ajax({
            url: '/api/user/info?userId=' + userId,
            data: JSON.stringify(data),
            type: 'POST',
            contentType: 'application/json',
            dataType: 'json',
            traditional: true,
            success: function (data) {
                layer.msg(data.msg)
                console.log(data.msg)
                if (data.code == 0) {
                    $('#modifyitem').modal('hide')
                    location.reload()
                } else {

                }
            }
        })
    })

    $('.collectdel').click(function () {
        var itemId = $($(this).parents('.col-md-1')).attr('id')
        var userId = localStorage.getItem('userId')

        console.log(itemId)
        $.ajax({
            url: '/api/collection/remove?collectionId=' + userId + '&itemId=' + itemId,
            type: 'POST',
            contentType: 'application/json',
            dataType: 'json',
            traditional: true,
            success: function (data) {
                if (data.code == 0) {
                    console.log('success')
                    $(this).parents('.tab-content').remove()
                }
                layer.msg(data.msg)
                console.log(data.msg)
                location.reload()
                //   $("#my_order").trigger('click');
            }
        })
    })

    $('.wantsdel').click(function () {
        var itemId = $($(this).parents('.col-md-1')).attr('id')
        var userId = localStorage.getItem('userId')

        console.log(itemId)
        $.ajax({
            url: '/api/wants/remove?userId=' + userId + '&wantsId=' + itemId,
            type: 'POST',
            contentType: 'application/json',
            dataType: 'json',
            traditional: true,
            success: function (data) {
                if (data.code == 0) {
                    console.log('success')
                    $(this).parents('.tab-content').remove()
                }
                layer.msg(data.msg)
                console.log(data.msg)
                location.reload()

            }
        })
    })

    $('.itemdel').click(function () {
        var itemId = $($(this).parents('.col-md-1')).attr('id')
        var userId = localStorage.getItem('userId')

        console.log(itemId)
        $.ajax({
            url: '/api/item/remove?userId=' + userId + '&itemId=' + itemId,
            type: 'POST',
            contentType: 'application/json',
            dataType: 'json',
            traditional: true,
            success: function (data) {
                // if(data.code==0){
                //     console.log("success")
                //     $($(this).parents(".tab-content")).remove();
                // }
                layer.msg(data.msg)
                console.log(data.msg)
                location.reload()
            }
        })
    })

    $('.orderdel').click(function () {
        var orderId = $($(this).parents('.col-md-1')).attr('id')
        var userId = localStorage.getItem('userId')

        // console.log(itemId);
        $.ajax({
            url: '/api/order/remove?userId=' + userId + '&orderId=' + orderId,
            type: 'POST',
            contentType: 'application/json',
            dataType: 'json',
            traditional: true,
            success: function (data) {
                // if(data.code==0){
                //     console.log("success")
                //     $($(this).parents(".tab-content")).remove();
                // }
                layer.msg(data.msg)
                console.log(data.msg)
                location.reload()
            }
        })
    })
</script>

</html>
